<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the polyline to add
$longitudes 	= "415.54556|416.54556|417.54556|418.54556|419.54556";
$latitudes 		= "3056.3179|3057.3179|3056.3179|3057.3179|3056.3179";

// the color of the polyline
$Color['red'] = 0;
$Color['green'] = 0;
$Color['blue'] = 255;
$Color['alpha'] = 150;

//Color of the Arrow
$ArrowColor['red'] = 255;
$ArrowColor['green'] = 255;
$ArrowColor['blue'] = 255;
$ArrowColor['alpha'] = 255;

// zoomlevel
$mapViewClippingWidth = 5000;
$mapViewPercentage = 20;


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new Polyline
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Polyline = new DeclareMap24Polyline();
$commands[$cmdIdx]->DeclareMap24Polyline->MapObjectID = "polyline";
$commands[$cmdIdx]->DeclareMap24Polyline->Coordinates = new CoordinatesArray();
$commands[$cmdIdx]->DeclareMap24Polyline->Coordinates->Longitudes = $longitudes;
$commands[$cmdIdx]->DeclareMap24Polyline->Coordinates->Latitudes = $latitudes;
$commands[$cmdIdx]->DeclareMap24Polyline->Color = new Color();
$commands[$cmdIdx]->DeclareMap24Polyline->Color->red = $Color['red'];
$commands[$cmdIdx]->DeclareMap24Polyline->Color->green = $Color['green'];
$commands[$cmdIdx]->DeclareMap24Polyline->Color->blue = $Color['blue'];
$commands[$cmdIdx]->DeclareMap24Polyline->Color->alpha = $Color['alpha'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor = new Color();
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->red = $ArrowColor['red'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->green = $ArrowColor['green'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->blue = $ArrowColor['blue'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->alpha = $ArrowColor['alpha'];

// this object will enable the polygon on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "ENABLE";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array("polyline");

// this object will center the map above the polygon
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->MapObjectIDs = array("polyline");
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;
$commands[$cmdIdx]->SetMapView->ClippingWidth->ViewPercentage = $mapViewPercentage;

// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;

?>